package com.elitesland.system.aop;

import com.elitesland.system.service.SysUdcProxyService;
import lombok.AllArgsConstructor;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * <pre>
 *     针对数据库返回结果集进行切面处理UDC的转换
 * </pre>
 *
 * @author Mir
 * @date 2020-04-20
 */

@Aspect
@Component
@AllArgsConstructor
public class SysCodeAop {

    private final SysUdcProxyService sysUdcProxyService;

    @Pointcut("@annotation(com.elitesland.system.annotation.SysCodeProc)")
    public void sysCodeCut() {
    }

    @Around("sysCodeCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        var result = point.proceed();

        return sysUdcProxyService.translate(result);
    }
}
